<template>
	<!--index.wxml-->

	<view class="container">
		<view class="swiper-box">
			<view class="nickname-box">
				<view class="nickname">
					<image :src="userInfo.photo" class="headimg"></image>
					<view>{{userInfo ? userInfo.nickname : ''}}!你好</view>
				</view>
			</view>
			<image src="/static/images/bg@2x.png" class="backimg"></image>
			<view class="inner">
				<view class="list" @tap="uselist">
					<view class="left">
						<view class="text-title">使用记录</view>
						<view style="padding:0px 10px;">
							<view class="text-btn">立即查看</view>
						</view>
					</view>
					<view class="right">
						<image src="/static/images/shiyongjilu@2x.png" class></image>
					</view>
				</view>
				<view class="list" @tap="obligation">
					<view class="left">
						<view class="text-title">等待付款</view>
						<view style="padding:0px 10px;">
							<view class="text-btn">立即查看</view>
						</view>
					</view>
					<view class="right">
						<image src="/static/images/dengdaifukuan@2x.png" class></image>
					</view>
				</view>
			</view>
		</view>
		<view class="list-mine">
			<view class="list-cell" @tap="totext(8)" data-cate="产品介绍">
				<image src="/static/images/chanpjs@2x.png"></image>
				<view>产品介绍</view>
				<image style="position:absolute; right:0px;" src="/static/images/right.png"></image>
			</view>
			<!-- <view class="list-cell" @tap="tojoin">
				<image src="/static/images/zhaosjs@2x.png"></image>
				<view>招商加盟介绍</view>
				<image style="position:absolute; right:0px;" src="/static/images/right.png"></image>
			</view> -->
			<view class="list-cell" @tap="totext(121)" data-cate="公司介绍">
				<image src="/static/images/gsjs@2x.png"></image>
				<view>公司介绍</view>
				<image style="position:absolute; right:0px;" src="/static/images/right.png"></image>
			</view>
			<view class="list-cell" @tap="removeLogin">
				<image src="/static/images/fkjs@2x.png"></image>
				<view>退出登录</view>
				<!-- <image style="position:absolute; right:0px;" src="/static/images/right.png"></image> -->
			</view>
		</view>
		
		<!-- 登录弹窗 -->
		<ns-login ref="login" @loginSuccess="loginSuccess"></ns-login>
		
	</view>
</template>

<script>
	//index.js
	const app = getApp().globalData;
	import { aliGetUser } from '@/api/setting.js'
	import nsLogin from "../../components/ns-login/ns-login.vue"
	export default {
		data() {
			return {
				background: ["/static/images/agent_img01599810087.jpeg", "/static/images/idimg01599807828.jpeg",
					"/static/images/idimg11599810002.jpeg"
				],
				indicatorDots: true,
				vertical: false,
				autoplay: false,
				interval: 2000,
				duration: 500,
				// userInfo: "",
				userInfo: {},
				user: "",
				photo: '',
			};
		},

		components: {
			nsLogin
		},
		props: {},
		onLoad: function() {
			console.log(uni.getStorageSync('userInfo'), 'userinfo')
			// this.userInfo = uni.getStorageSync('userInfo')
			// app.employCallback = employ => {
			//   console.log(app.userInfo);

			//   if (employ != '') {
			//     this.setData({
			//       userInfo: app.user_info
			//     });
			//   }
			// };

			this.setData({
				user: app.user_info
			});
			console.log(this.user);
		},
		onShow: function() {
			console.log(11);
			var _this = this;
			_this.userInfo = uni.getStorageSync('userInfo')
			// _this.photo = uni.getStorageSync('userInfo') ? uni.getStorageSync('userInfo').photo : ''
		},
		methods: {
			// 退出登录
			removeLogin(){
				aliGetUser({
					uid: wx.getStorageSync('userInfo').user_id
				}).then(res=>{
					console.log(res,'退出登录')
					// my.clearStorage()
					// my.removeStorageSync({key: 'openId'});
					// my.removeStorageSync({key: 'accessToken'});
					// my.removeStorageSync({key: 'userInfo'});
					// my.removeStorageSync({key: 'login_check'});
				})
				
			},
			touselist: function() {
				if (this.userInfo) {
					uni.navigateTo({
						url: '/pages/uselist/index'
					});
				}else {
					uni.showToast({
						title:'请先登录',
						icon: 'none'
					})
				}
				
			},
			obligation: function() {
				if (this.userInfo) {
					uni.navigateTo({
						url: '/pages/obligation/index'
					});
				}else {
					uni.showToast({
						title:'请先登录',
						icon: 'none'
					})
				}
				
			},
			uselist() {
				if (this.userInfo) {
					uni.navigateTo({
						url: '/pages/uselist/index'
					});
				}else {
					uni.showToast({
						title:'请先登录',
						icon: 'none'
					})
				}
				
				
			},
			totext(e) {
				console.log(e, 'eee');
				uni.navigateTo({
					url: '/pages/textare/index?cate=' + e
				});
			},
			tojoin: function() {
				uni.navigateTo({
					url: '/pages/joinus/index'
				});
			},
			toFankui(){
				uni.showToast({
					title: '开发中',
					icon: 'none'
				})
			},

			handleChange({
				detail
			}) {
				console.log(detail);
			}

		}
	};
</script>
<style>
	@import "./index.css";
</style>